package com.sky.mapper;

import com.sky.dto.GoodsSalesDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Mapper
public interface ReportMapper {

    /**
     * 根据日期查询营业额
     * @param beginTime endTime
     * @return
     */
    @Select("select sum(amount) from orders where status = 5 and order_time > #{beginTime} and order_time < #{endTime}")
    Double getTurnoverByDate(LocalDateTime beginTime, LocalDateTime endTime);

    /**
     * 根据日期查询用户数
     * @param
     * @return
     */
//    @Select("Select * from user where create_time > #{beginTime} and endTime < #{endTime}")
    Long countByMap(Map map);

    /**
     * 根据日期查询订单数
     * @param map
     * @return
     */
//    @select("select count(id) from orders where status = 5 and order_time > #{beginTime} and order_time < #{endTime}")
    Integer countOrderByMap(Map map);

    /**
     * 查询销量排名top10
     * @param beginTime
     * @param endTime
     * @return
     */
    List<GoodsSalesDTO> getTop10(LocalDateTime beginTime, LocalDateTime endTime);
}
